package com.hnevc.androiduiclassone3;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

private static final String TAG ="MainActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.con_layout);
        //获取按钮对象,并设置监听者
       Button button = findViewById(R.id.btn_login);
       //1 获取对象
        RadioGroup radioGroup = findViewById(R.id.rg_sex);
        //2设置radioGroup
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                Log.e(TAG, "onCheckedChanged: "+checkedId );
                switch (checkedId){
                    case R.id.rb_male:
                        Log.e(TAG, "onCheckedChanged: "+"男" );
                        break;
                    case R.id.rb_female:
                        Log.e(TAG, "onCheckedChanged: "+"女" );
                        break;
                }
            }
        });
    }

    public void login(View view) {
        Log.e(TAG, "login: " +((Button)view).getText() );
    }

    @Override
    public void onClick(View v) {
        Log.e(TAG, "onClick: "+"监听器" );
    }
}
